package com.yupi.springbootinit.bizmq;

import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;
import com.rabbitmq.client.ConnectionFactory;

/**
 * 用于添加bi相关的交换机和队列（只用执行一次）
 */
public class BIMQInitMain {

    public static void main(String[] args) {
        ConnectionFactory factory = new ConnectionFactory();
        factory.setHost("localhost");
        try (Connection connection = factory.newConnection();
             Channel channel = connection.createChannel()) {
            channel.exchangeDeclare(BIMQConstant.BI_EXCHANGE_NAME, "direct");
            channel.queueDeclare(BIMQConstant.BI_QUEUE_NAME,true,false,false,null);
            channel.queueBind(BIMQConstant.BI_QUEUE_NAME,BIMQConstant.BI_EXCHANGE_NAME,BIMQConstant.BI_ROUTING_KEY);


        }catch (Exception e){

        }
    }
}
